import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserEntity } from '../entity/user.entity';
import { RoleEntity } from 'src/entity/role.entity';
import { UserRoleEntity } from 'src/entity/user.role.entity';
import { AccessEntity } from 'src/entity/access.entity';
import { RoleAccessEntity } from 'src/entity/role_access.entity';
import { CategoryEntity } from 'src/entity/category.entity';
import { TagEntity } from 'src/entity/tags.entity';
import { PostEntity } from 'src/entity/posts.entity';

import { UserController } from './background/user/user.controller';
import { LoginController } from './background/login/login.controller';
import { RoleController } from './background/role/role.controller';
import { AccessController } from './background/access/access.controller';
import { RoleAccessController } from './background/role-access/role-access.controller';
import { CategoryController } from './background/category/category.controller';
import { TagController } from './background/tag/tag.controller';
import { PostController } from './background/post/post.controller';

import { UserService } from '../service/user/user.service';
import { ToolsService } from 'src/tools/tools/tools.service';
import { RoleService } from 'src/service/role/role.service';
import { AccessService } from 'src/service/access/access.service'
import { RoleAccessService } from 'src/service/role-access/role-access.service';
import { CategoryService } from 'src/service/category/category.service';
import { TagService } from 'src/service/tag/tag.service';
import { PostService } from 'src/service/post/post.service';
import { AuthService } from './common/auth/auth.service';
import { CacheService } from 'src/tools/redis/redis.cache.service';
import { OssService } from 'src/service/upload/oss/oss.service';

import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { JwtStrategy } from 'src/modules/common/auth/strategies/jwt.strategy'
import { LocalStrategy } from './common/auth/strategies/local.strategy';
// 文件上传配置
// import { MulterModule } from '@nestjs/platform-express';
// import { ConfigService } from 'nestjs-config';
@Module({
  imports: [
    TypeOrmModule.forFeature([UserEntity, RoleEntity, UserRoleEntity, AccessEntity, RoleAccessEntity, CategoryEntity, TagEntity, PostEntity]),
    // PassportModule.register({ defaultStrategy: 'jwt' }),
    PassportModule,
    JwtModule.register({
      secret: process.env.SECRET,
      signOptions: { expiresIn: '7200s' }, // token 过期时效
    }),
    // 本地上传文件配置 已经接了腾讯云 暂时注掉
    // MulterModule.registerAsync({
    //   useFactory: (config: ConfigService) => config.get('file'),
    //   inject: [ConfigService],
    // }),
  ],
  controllers: [UserController, LoginController, RoleController, AccessController, RoleAccessController, CategoryController, TagController, PostController],
  providers: [UserService, ToolsService, RoleService, AccessService, RoleAccessService, CategoryService, TagService, PostService, JwtStrategy, LocalStrategy, AuthService, CacheService,OssService],
})
export class BackgroundModule { }
